<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="login">登录</button>
    <script>
        function login() {
            return "管理员"
        }
        let obtn = document.querySelector("#login")
        obtn.onclick = function () {
            let role = login()
            console.log(role)
            render(role)
        }
        async function render(role) {
            if (role === "管理员") {
                //加载1.js
                let res1 = await import("./1.js") //返回的是promise对象
                console.log(res1)

            } else {
                //加载2.js
                let res2 = await import("./2.js")
                console.log(res2)
            }
        }

    </script>
</body>

</html>